//
//  YSSqliteModelToolTest.m
//  YSSqliteTool_Tests
//
//  Created by Kyson on 2018/12/4.
//  Copyright © 2018 kysonyangs. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "YSSqliteModelTool.h"
#import "YSStu.h"

@interface YSSqliteModelToolTest : XCTestCase

@end

@implementation YSSqliteModelToolTest

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testCreateTable {
    BOOL result = [YSSqliteModelTool createTable:[YSStu class] uid:nil];
    XCTAssertEqual(result, YES);
}

- (void)testTableEqual {
    BOOL result = [YSSqliteModelTool isTableRequiredUpdate:[YSStu class] uid:nil];
    XCTAssertEqual(result, YES);
}

- (void)testUpdateTable {
    BOOL result = [YSSqliteModelTool updateTable:[YSStu class] uid:nil];
    XCTAssertEqual(result, YES);
}

- (void)testSave {
    YSStu *model = [[YSStu alloc] init];
    model.stuNum = 3;
    model.age = 20;
    model.score = 100;
    model.name = @"xixi";
    model.likes = @[@"apple",@"banana",@"orange"];
    model.familty = @{@"father":@"lisi",@"mather":@"meili"};
    BOOL result = [YSSqliteModelTool saveOrUpdateModel:model uid:nil];
    XCTAssertEqual(result, YES);
}

- (void)testUpate {
    YSStu *model = [[YSStu alloc] init];
    model.stuNum = 2;
    model.age = 30;
    model.score = 77;
    model.name = @"lilili";
    model.likes = @[@"apple",@"banana",@"orange"];
    model.familty = @{@"father":@"lisi",@"mather":@"meili"};
    BOOL result = [YSSqliteModelTool saveOrUpdateModel:model uid:nil];
    XCTAssertEqual(result, YES);
}

- (void)testDelete {
    YSStu *model = [[YSStu alloc] init];
    model.stuNum = 1;
    BOOL result = [YSSqliteModelTool deleteModel:model uid:nil];
    XCTAssertEqual(result, YES);
}

- (void)testQuery {
    NSArray *result = [YSSqliteModelTool queryAllModels:[YSStu class] uid:nil];
    NSLog(@"%@", result);
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

@end
